package com.vidyu.servicelayer.serviceinterface.Impl;

import com.vidyu.businesslayer.businesscomponents.*;
import com.vidyu.businesslayer.businesscomponents.trackingmerger.TrackingReceiver;
import com.vidyu.businesslayer.businessentities.*;
import com.vidyu.servicelayer.servicedataentitties.*;
import com.vidyu.servicelayer.serviceinterface.ControllerServiceWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;


/**
 * Created by IntelliJ IDEA.
 * Session: eyalsa
 * Date: 06/03/12
 * Time: 15:44
 * ControllerServiceWrapper handle all agency business
 */
@Component
public class ControllerServiceWrapperImpl implements ControllerServiceWrapper {

    @Autowired
    private TrackingReceiver trackingReceiver;

    @Autowired
    private SkillHandler skillHandler;

    @Autowired
    private EmployerHandler employerHandler;

    @Autowired
    private ContractorHandler contractorHandler;

    @Autowired
    private MsgHandler msgHandler;

    @Autowired
    private ProjectHandler projectHandler;

    @Autowired
    private ContractHandler contractHandler;

    public void saveTracking(String userParams){
        trackingReceiver.saveTracking(userParams);
    }

    @Override
    public long addSkill(String title, String skillDesc) {
        return skillHandler.addSkill(title, skillDesc);
    }

    public long addEmployer(EmployerRO employerRO){
        return employerHandler.addEmployer(employerRO);
    }
    public long addContractor(ContractorRO contractorRO){
        return contractorHandler.addContractor(contractorRO);
    }
    public Employer getEmployerByEmailAndPassword(String email, String password){
        return employerHandler.getEmployerByEmailAndPassword(email, password);
    }

    public Contractor getContractorByEmailAndPassword(String email, String password){
        return contractorHandler.getContractorByEmailAndPassword(email, password);
    }

    public long addProjectToEmployer (ProjectRO projectRO){
        return projectHandler.addProjectToEmployer(projectRO);
    }

    public void updateProject(ProjectRO projectRO){
        projectHandler.updateProject(projectRO);
    }

    public void setSkillsToContractor(SkillsRO skillsRO){
        contractorHandler.setSkillsToContractor(skillsRO);
    }

    public long addMsg(MsgRO msgRO){
        return msgHandler.addMsg(msgRO);
    }

    public void updateMsgStatus(MsgRO msgRO){
        msgHandler.updateMsgStatus(msgRO);
    }

    public List<Msg> getMsgInbox(long fromId){
        return msgHandler.getMsgInbox(fromId);
    }

    public long contractorApplyToProject(UserInProjectRO userInProjectRO){
        return  projectHandler.contractorApplyToProject(userInProjectRO);
    }
    public void updateUserInProject(UserInProjectRO userInProjectRO){
        projectHandler.updateUserInProject(userInProjectRO);
    }
    public List<UserInProject> getUsersInProjectByStatus(long projectId, String status){
        return projectHandler.getUsersInProjectByStatus(projectId, status);
    }

    public List<Pair<Long, String>> getAllContractTitles(){
        return contractHandler.getAllContractTitles();
    }

    public Pair<String, String> getContract(long id){
        return contractHandler.getTitleAndContent(id);
    }

}

